Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy returned bytes from TSI meta functions. #8975

Merged
merged 4 commits into from
Oct 18, 2017

Conversation

benbjohnson
Copy link
Contributor

@benbjohnson benbjohnson commented Oct 17, 2017

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@benbjohnson benbjohnson self-assigned this Oct 17, 2017
@benbjohnson benbjohnson requested a review from e-dard October 17, 2017 20:06
@ghost ghost added the review label Oct 17, 2017
Copy link
Contributor

@e-dard e-dard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Does this not need to be added anywhere else though? It's not clear to me when we need to copy slices and when we don't. Maybe some comments/doc could leave future hints 😄

@@ -802,6 +802,15 @@ func copyBytes(b []byte) []byte {
return buf
}

// copyBytes returns a copy of a slice of byte slices.
func copyByteSlices(a [][]byte) [][]byte {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any qualms about this being here, but it could also live happily alongside Union(a, b [][]byte) [][]byte and Intersect(a, b [][]byte) [][]byte in the bytesutil package. Maybe as Clone(a [][]byte) [][]byte?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I moved these up to bytesutil in d17d0f1.

@benbjohnson
Copy link
Contributor Author

@e-dard I added comments about the byte copying in 8ad2048. The slices just need to be copied if they will be used after the fileset is released. Within the FileSet.Retain() & FileSet.Release() the files are guaranteed to stay memory-mapped.

@e-dard
Copy link
Contributor

e-dard commented Oct 18, 2017

@benbjohnson ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ DoUbLe ApProVE ⭐️ ⭐️ ⭐️ ⭐️ ⭐️

@benbjohnson benbjohnson merged commit 62093d2 into influxdata:master Oct 18, 2017
@ghost ghost removed the review label Oct 18, 2017
@benbjohnson benbjohnson deleted the tsi-copy-returned-bytes branch October 18, 2017 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants